﻿using System;
using ChangingValidationFromAndbyAggregate.Dominio;
using ChangingValidationFromAndbyAggregate.Validators;
using Moq;
using NHibernate.Validator.Cfg.Loquacious;
using NHibernate.Validator.Engine;
using NUnit.Framework;
using SharpTestsEx;

namespace ChangingValidationFromAndbyAggregate.Test.Dominio
{
    [TestFixture]
    public class GivenAnOrder
    {
        private ValidatorEngine _validatorEngine;

        [TestFixtureSetUp]
        public void SettingValidationEngine()
        {
            var fluentConfiguration = new FluentConfiguration();
            var definitionsOfValidations = new[]
                                  {
                                      typeof (OrderValidation)
                                  };
            fluentConfiguration.Register(definitionsOfValidations);

            _validatorEngine = new ValidatorEngine();
            _validatorEngine.Configure(fluentConfiguration);
        }

        [Test]
        public void WhenIWantAnOrderEntityThenCreateAn()
        {
            var customer = new Mock<ICustomer>();
            var entidadeOrder = new Order(customer.Object);

            Assert.AreEqual("order", entidadeOrder.GetType().Name.ToLower());
        }

        [Test]
        public void WhenTheOrderNeedsToHaveACustomerThenAssociateACustomer()
        {
            var customer = new Customer();
            var order = new Order(customer);

            Assert.IsNotNull(order.Customer);
            Assert.AreEqual(typeof (Customer), order.Customer.GetType());
        }

        [Test]
        public void WhenITryToCreateAValidThenCreateAValid()
        {
            var customer = new Customer();
            var order = new Order(customer);

            order.Satisfy(o => _validatorEngine.IsValid(o));
        }

        [Test]
        public void WhenHaveAnValidatorOfOrderThenTestThisValidator()
        {
            var orderValidation = new OrderValidation();
            var a = 1;


        }
    }
}
